package com.os.meituan.service.sec;

import com.os.meituan.common.PubClass;
import com.os.meituan.common.XJsonInfo;
import com.os.meituan.model.pomodel.sec.T_SYS_Log;
import com.os.meituan.repository.SYS_LogRepository;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.concurrent.Future;

@Service
public class SYS_AsyncService {
    @Resource

    private PubClass pubClass;
    @Resource
    private SYS_LogRepository sys_logRepository;
    @Async
    public Future<XJsonInfo> save(T_SYS_Log info) {
        if (info == null) {
            pubClass.showLog("info是null");
            return new AsyncResult<>(new XJsonInfo(false));
        }
        if (info.getUserId() == null) {
            pubClass.showLog("info不是null，但是userId是null,当前username是：" + info.getUserName());
            return new AsyncResult<>(new XJsonInfo(false));
        }
//        info.setId(pubClass.getNewID());
//        sys_logMapper.insert(info);
        sys_logRepository.save(info);
//        sendLogToBingo(info);
        return new AsyncResult<>(new XJsonInfo());
    }
}
